Insert a new itemΒΆ
A.insert(i, N)
Insert a new item before the second element in an existing array.
from array import *
AI = array('i', [1, 3, 5, 7, 9])
print("Original array: " + str(AI))
# Original array: array('i', [1, 3, 5, 7, 9])
print("Insert new value 4 before 3:")
AI.insert(1, 4)
print("New array: " + str(AI))
# array('i', [1, 4, 3, 5, 7, 9])
See also: https://www.w3resource.com/python-exercises/array/python-array-exercise-10.php